﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SR_MessageDemo.Messages;

namespace SR_MessageDemo
{
    public partial class FormEdit : Form
    {
        private User user;

        public FormEdit(User _user)
        {
            InitializeComponent();
            this.Role.Items.AddRange(new object[] { "非管理员", "管理员" });
            this.user = _user;
            this._Name.Text = _user.Name;
            this.Age.Text = _user.Age.ToString();
            this.Gender.Text = _user.Gender;
            this.Role.Text = user.Role ?? "非管理员";
        }

     
        private void FormEdit_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            user.Name =this._Name.Text ;
            user.Age =Convert.ToInt32(this.Age.Text);
            user.Gender=this.Gender.Text;
            user.Role=this.Role.Text??"非管理员";
            //mainForm.HideMenus(user);
            WeakReferenceMessager.Default.Send(user);
        }
    }
}
